#pragma once
#include "uitool.h"
#include <list>
#include <mathlib.h>

//#include "DecoMeasure.h"

class DecoSceneObject;
class DecoWall;
class DecoScene;

class Deco3dUITool :
	public UITool
{
public:
	enum UIMode{
		ptrT = 0,              // select object
		panT = 1,			   // move object
		rotateT = 2,		   // rotate object
		resizeT = 3,            // resize object
		measureT = 4			// measure distance
	};
public:
	Deco3dUITool(void);
	virtual ~Deco3dUITool(void);
public:
	virtual void init(DecoScene* scene);
	virtual void exit();
	virtual BOOL onLButtonDown(FLOAT x, FLOAT y);
	virtual BOOL onRButtonDown(FLOAT x, FLOAT y);
	virtual BOOL onLButtonUp(FLOAT x, FLOAT y);
	virtual BOOL onRButtonUp(FLOAT x, FLOAT y);
	virtual BOOL onMouseMove(FLOAT x, FLOAT y);
	virtual BOOL onMouseScroll(FLOAT z);
	virtual BOOL onKeyDown(char key);
	virtual BOOL onKeyUp(char key);

	//void NotifyNewlyAdded(DecoSceneObject* pObj);
	//void NotifyNewlyAdded(const std::string& texpath);

	//DecoSceneObject* GetNewlyAddedObject()const;
	//const std::string& GetNewlyAddedTexture()const;

	DecoSceneObject* GetFocusedObj()const;
	void UpdateMiscStuff();
	void SetUIMode(UIMode md);
	Deco3dUITool::UIMode GetUIMode()const;
	//static void NotifyDelNewlyAdded(DecoSceneObject* obj);
private:
	enum InternalMode{
		walkT = 0,//walk in scene , a,s,d,w
		moveT = 1,//move objs
		rotT = 2, //rotate objs
		orbitT = 3, //orbit in scene
		reszT = 4,
		//measureT = 5,   // do nothing while in measure mode
		nullT //nothing
	};

	enum MeasureMode{
		measureNullT = 0,
		measureMoveT = 1
	};
	
	BOOL isShiftDown;
	INT numberButton;
	InternalMode mode;
	UIMode uimode;
	//MeasureMode measureMode;

	//put new objects
	//DecoSceneObject* focusObj;
	//static DecoSceneObject* newlyAddedObj;

	//attach new wallpapers
	//std::string newlyAddedTexPath;
	//std::string prevTexPath;
	//DecoSceneObject* prevAttachedObj;
	//DecoWall* prevInsideWall;

	//mouse positions
	FLOAT lastX;
	FLOAT lastY;

	FLOAT lastMouseDownX;
	FLOAT lastMouseDownY;

	//keep the original dimension of the window/door
	FLOAT reszX;
	FLOAT reszY;

	DecoScene* scene;

	//keep information for measurement
	//vector3	measureStartPoint;
	//vector3 measureEndPoint;
	//FLOAT	measureLength;
};
